package cn.com.huzo.service.trade.impl;

import cn.com.huzo.model.entities.trade.InspectionJournalLinesCertificationLinesEntity;
import cn.com.huzo.repository.trade.InspectionJournalLinesCertificationLinesRepository;
import cn.com.huzo.service.trade.InspectionJournalLinesCertificationLinesManager;
import huzofw.service.impl.GenericManagerImpl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 化检日记账合格证明细管理服务对象类实现。
 *
 * @author 范学春
 */
@Service("InspectionJournalLinesCertificationLinesManager")
public class InspectionJournalLinesCertificationLinesManagerImpl extends GenericManagerImpl<InspectionJournalLinesCertificationLinesEntity, String>
        implements InspectionJournalLinesCertificationLinesManager {

    @Resource(name = "InspectionJournalLinesCertificationLinesRepository")
    private InspectionJournalLinesCertificationLinesRepository _dao;

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    @Transactional
    public Map<String, Object> batchInsert(Map<String, Object> criterion) throws Exception {
        _dao.insert(criterion);
        // 返回值
        Map<String, Object> _result = new HashMap();
        _result.put("LinesList", _dao.fetchByHeaderKey(MapUtils.getString(criterion, "CertificationLinesId")));

        return _result;
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public Integer updateLines(List<InspectionJournalLinesCertificationLinesEntity> itemList) throws Exception {
        return _dao.update(itemList);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    @Transactional
    public List<InspectionJournalLinesCertificationLinesEntity> deleteLines(InspectionJournalLinesCertificationLinesEntity instance) throws Exception {
        _dao.delete(instance.getLinesId());
        return _dao.fetchByHeaderKey(instance.getCertificationLinesId());
    }
}
